﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///BetweenSearchRun 的摘要说明
/// </summary>
public class BetweenSearchRun:ISearchRunType
{
	public BetweenSearchRun()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    #region ISearchRunType 成员

    public string GetSearchString(ConfigColumns cCol, string Value)
    {
        if (Value == ",")
        {
            return string.Empty;
        }
        string[] arr = Value.Split(',');
        string r = string.Empty;
        if (arr.Length > 1)
        {
            if (!string.IsNullOrEmpty(arr[0]) && !string.IsNullOrEmpty(arr[1]))
            {
                r = cCol.ColumnName + " between " + DataTypeFactory.GetSqlValue(arr[0], cCol.ColumnDataType) + " and " + DataTypeFactory.GetSqlValue(arr[1], cCol.ColumnDataType);
            }
            else if (string.IsNullOrEmpty(arr[0]))
            {                
                r = new LessAndEqualSearchRun().GetSearchString(cCol, arr[1]);
            }
            else if (string.IsNullOrEmpty(arr[1]))
            {                
                r = new LagerAndEqualSearchRun().GetSearchString(cCol, arr[0]);
            }
            else
            {
                r = string.Empty;
            }
        }
        else
        {            
            r = new LagerAndEqualSearchRun().GetSearchString(cCol, Value);
        }

        return r;
    }

    #endregion
}
